package com.gopay.common.security.validcode.manager.impl;

import java.util.Date;
import java.util.UUID;

import org.springframework.stereotype.Service;

import com.gopay.common.constants.validcode.CodeType;
import com.gopay.common.domain.vs.VsValidCodeDtl;
import com.gopay.common.util.DateUtils;

/**
 * 交易验证码实现
 * 
 * @TradeValidCodeManagerImpl.java
 * @author yaobo
 * @2013-5-15 下午03:43:51 www.gopay.com.cn Inc.All rights reserved.
 */
@Service("tradeValidCodeManager")
public class TradeValidCodeManagerImpl extends AbstractValidCode {
    // 过期时间(秒)
    private final static int EXPIR = 120;

    @Override
    protected VsValidCodeDtl generateCode(CodeType type, String voID) {
        VsValidCodeDtl code = new VsValidCodeDtl();

        // 生成随机码
        String uid = UUID.randomUUID().toString();
        uid = uid.substring(0, 6).toUpperCase();

        // 当前时间
        Date curDate = DateUtils.getSystemDate();

        expirTime = EXPIR;

        code.setCode(uid);
        code.setType(type.value);
        code.setVoID(voID);
        code.setExpir(expirTime);
        code.setCreated(curDate);
        code.setModified(curDate);

        return code;
    }

	@Override
	public boolean valid(CodeType type, String voID, String code, String timeOut) {
		// TODO Auto-generated method stub
		return false;
	}

}
